﻿using System;
using System.Collections.Generic;
using System.Globalization;
using NTTDATA.BEENChina.ResultCertification.Config; 

namespace NTTDATA.BEENChina.ResultCertification.Checker.Text
{
    [Serializable]
    [VerfityAttribute(Id = "VerfityTX0406", Name = "包含[歯]且包含2个以上连续的数字～组合,且不包含黑字图[]时抽出", CategoryType = EnumCategoryType.文字列, Model = true)]
    public class VerfityTx0406 : VerfityOneResult
    {
        

        public override bool CheckResult(List<List<string>> result, string entryCommon)
        {
            bool bresult = false;

            if (entryCommon == "30"  ||
                 entryCommon == "20")
            {
                return false;
            }

            foreach (var rowResult in result)
            {
                foreach (var colResult in rowResult)
                {

                    bresult = CheckErrorResult(colResult);

                    if (bresult)
                        break;
                }

                if (bresult)
                    break;
            }


            if (bresult)
            {
                System.Console.WriteLine("VerfityTX0406"); 
            }
            return bresult;
        }

        /// <summary>
        /// 包含[歯]且包含2个以上连续的数字～组合,且不包含黑字图[]时抽出
        /// </summary>
        /// <param name="colResult"></param>
        /// <returns></returns>
        private bool CheckErrorResult(string colResult)
        {
            if (colResult.Contains("歯") &&
                ContainsTwoNumber(colResult) &&
                !colResult.Contains(""))
            {
                return true;
            }

            return false;

        }

        private bool ContainsTwoNumber(string result)
        {
            
            for (int i = 0; i < 100; i++)
            {
                if (result.Contains(i.ToString(CultureInfo.InvariantCulture)))
                    return true;
                  
            }
            return false;
        }


    }
}